﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;
using Entidades.Karaoke;

namespace Datos.Generico
{
    public class GenUsuarioDAL
    {
        public static string cnx = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString();


        public static bool Autenticar(string usuario, string password)
        {

            string sql = @"SELECT COUNT(*)
                       FROM Gen_Usuario
                       WHERE codUsuario = @usuario AND password = @password";

            SqlConnection con = new SqlConnection(cnx);
            SqlCommand com = new SqlCommand(sql, con);
            com.CommandType = System.Data.CommandType.Text;

            com.Parameters.AddWithValue("@usuario", usuario);
            com.Parameters.AddWithValue("@password", password);
            try
            {
                con.Open();
                int count = Convert.ToInt32(com.ExecuteScalar());

                if (count == 0)
                    return false;
                else
                    return true;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }

    }
}
